package mylab.starters.mq.config;

import lombok.Data;
import lombok.EqualsAndHashCode;
import mylab.starters.mq.api.Properties;
import mylab.utils.spring.spi.DefaultProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;

import static mylab.utils.spring.constants.PropertyConst.PROPERTIES_PREFIX;

@Data
@EqualsAndHashCode(callSuper = false)
@ConfigurationProperties(prefix = MqPropperties.PREFIX)
public class MqPropperties {
    static final public String PREFIX = PROPERTIES_PREFIX + ".mq";

    private OnsTcpProperties onsTcp = new OnsTcpProperties();
    private OnsHttpProperties onsHttp = new OnsHttpProperties();
    private KafkaMqProperties kafka = new KafkaMqProperties();
    private RocketMqProperties rocketmq = new RocketMqProperties();
    private RabbitMqProperties rabbitmq = new RabbitMqProperties();
    private RedisMqProperties redis = new RedisMqProperties();
    private LocalMqProperties local = new LocalMqProperties();

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class OnsTcpProperties extends CommonProperties {
    }

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class OnsHttpProperties extends CommonProperties {
        private String instanceId;
    }

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class KafkaMqProperties extends CommonProperties {
    }

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class RocketMqProperties extends CommonProperties {
    }

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class RabbitMqProperties extends CommonProperties {
        private String user;
        private String password;
        private String virtualHost;
    }

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class RedisMqProperties extends CommonProperties {
        private String password;
    }

    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class LocalMqProperties extends CommonProperties {
    }

    @EqualsAndHashCode(callSuper = true)
    @Data
    public static class CommonProperties extends DefaultProperties implements Properties {

        private String brokers;

    }

}
